//
//  JMVerifyTopView.m
//  NewiOSProject
//
//  Created by JMMac on 25.12.23.
//  Copyright © 2023 范智渊. All rights reserved.
//

#import "JMVerifyTopView.h"

@implementation JMVerifyTopView
- (instancetype)initWithFrame:(CGRect)frame model:(JMHomeModel*)model
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *topImgV = [[UIImageView alloc]initWithFrame:(CGRectMake(0, 0, kAppW(), 306))];
        [topImgV setImage:ImageNamed(@"home_top")];
        [self addSubview:topImgV];
        
        UIImageView *logoImgV = [[UIImageView alloc]initWithFrame:(CGRectMake(24, kSafeAreaTopHeight()+10, 32, 32))];
        [logoImgV setImage:ImageNamed(@"login_Logo")];
        [self addSubview:logoImgV];
        
        
        UILabel *Lab = [JMControl createLabelWithFrame:(CGRectMake(24, logoImgV.bottom+24, kAppW(), 20)) Font:fontWithWeight(14, UIFontWeightRegular) Text:@"Cuota total($)" color:WhiteColor()];
        [self addSubview:Lab];
        
        UILabel *maxLab = [JMControl createLabelWithFrame:(CGRectMake(24, Lab.bottom+12, kAppW(), 45)) Font:Font(32) Text:model.total.stringValue.moneyString.dollarPrefix color:Hex_Str_COLOR(@"#ffffff")];
        [self addSubview:maxLab];
        [JMControl changeTextFontWithLabel:maxLab changeStr:@"$" font:Font(22)];
        
        UIView*horlineV= [[UIView alloc]initWithFrame:(CGRectMake(0, maxLab.bottom+20, kAppW(), 0.5))];
        horlineV.backgroundColor = WhiteColor();
        [self addSubview:horlineV];
        
        
        CGFloat width = (kAppW()-48)/3;
        NSArray *titles = @[@"Cuota utilizada",@"Cuota congelada",@"Cuota disponible"];
        NSString *used =model.used?model.used.stringValue.moneyString.dollarPrefix:@"";
        NSString *locking =model.locking?model.locking.stringValue.moneyString.dollarPrefix:@"";
        NSString *unused =model.unused?model.unused.stringValue.moneyString.dollarPrefix:@"";
        NSArray *values = @[used,locking,unused];
        for (int i=0; i<3; i++) {
            UILabel *valueLab = [JMControl createLabelWithFrame:(CGRectMake(24+width*i, horlineV.bottom+17, width, 21)) Font:fontWithWeight(15, UIFontWeightMedium) Text:values[i] color:WhiteColor()];
            [self addSubview:valueLab];
            NSString *title = titles[i];
            
            UIView *verLineV = [[UIView alloc]initWithFrame:(CGRectMake(valueLab.right-15, valueLab.top, 1, 44))];
            verLineV.backgroundColor = WhiteColor();
            [self addSubview:verLineV];
            if (i==2) {
                verLineV.hidden = YES;
            }
            UILabel *keyLab = [JMControl createLabelWithFrame:(CGRectMake(valueLab.left,valueLab.bottom+11, valueLab.width, 17)) Font:[UIFont systemFontOfSize:11] Text:title color:Hex_Str_COLOR(@"#EBEBED")];
            [self addSubview:keyLab];
            keyLab.centerX = valueLab.centerX;
        }
        
    }
    return self;
}


@end
